#! /usr/bin/env python3
import cv2
import requests

url = "http://124.221.6.242:5000/upload_video"
# url = "http://127.0.0.1:5000/upload_video"


cap = cv2.VideoCapture(0)  # 从摄像头获取视频
while True:
    ret, frame = cap.read()
    if not ret:
        break

    _, buffer = cv2.imencode('.jpg', frame)
    response = requests.post(url, data=buffer.tobytes(),
                             headers={'Content-Type': 'application/octet-stream'})
    # if response.status_code != 200:
    #     print(f"Failed to send frame: {response.status_code}")
